//
//  CustomTipTableCell.m
//  YouGoWeGo
//
//  Created by LiuFei on 14/11/19.
//  Copyright (c) 2014年 LiuFei. All rights reserved.
//

#import "CustomTipTableCell.h"

@implementation CustomTipTableCell

- (void)dealloc
{
    [_tipView release];
    [_userLabel release];
    [_detailLabel release];
    [_headImage release];
    [_liked_count release];
    [_timeLabel release];
    [_tagLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setBackgroundColor:[UIColor colorWithRed:201 / 255.0 green:214 / 255.0 blue:231 / 255.0 alpha:1]];
        
//        self.tipView = [[UIView alloc] initWithFrame:CGRectZero];
//        [_tipView.layer setCornerRadius:10];
//        [_tipView setBackgroundColor:[UIColor colorWithRed:201 / 255.0 green:214 / 255.0 blue:231 / 255.0 alpha:1]];

//        [self addSubview:_tipView];
//        [_tipView release];
        
        self.headImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        [_headImage.layer setCornerRadius:25];
        [_headImage setClipsToBounds:YES];
        [self addSubview:_headImage];
        [_headImage release];
        
        self.userLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [self addSubview:_userLabel];
        [_userLabel release];
        
        self.tagLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [self addSubview:_tagLabel];
        [_tagLabel release];
        
        self.timeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [self addSubview:_timeLabel];
        [_timeLabel release];
        
        self.liked_count = [[UILabel alloc] initWithFrame:CGRectZero];
        [self addSubview:_liked_count];
        [_liked_count release];
        
        self.detailLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [_detailLabel setNumberOfLines:0];
        [_detailLabel setFont:[UIFont systemFontOfSize:14]];
        [self addSubview:_detailLabel];
        [_detailLabel release];
        

    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [_tipView sizeToFit];
    
    
    [_headImage setFrame:CGRectMake(10, 10, 50, 50)];
    [_userLabel setFrame:CGRectMake(80, 15, 80, 30)];
    [_tagLabel setFrame:CGRectMake(80, 50, 50, 20)];
    [_timeLabel setFrame:CGRectMake(120, 50, 200, 20)];
    [_liked_count setFrame:CGRectMake(300, 50, 40, 20)];
    
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14], NSFontAttributeName, nil];
    
    CGRect rect = [_detailLabel.text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 20, 400) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    [_detailLabel setFrame:CGRectMake(10, _headImage.frame.size.height + 20, [UIScreen mainScreen].bounds.size.width - 20, rect.size.height)];
    
//    [_tipView setFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width - 20, _headImage.frame.size.height + _detailLabel.frame.size.height + 40)];
}


@end
